<template>
	<view>

		<template v-for="item in datalist">

			<goods :item="item"></goods>

		</template>



	</view>
</template>

<script>
	import {
		ref,
		toRefs,
		reactive
	} from 'vue';
	export default {
		setup() {
			const datalist = ref([1, 2, 3]);

			//获取本地存储中的数据
			const tokenid = uni.getStorageSync("tokenid");

			console.log("get:", tokenid);

			const dataload = () => {
				uni.request({
					url: "https://8c0ca265-f640-4eda-a886-92bd742a95fa.bspapp.com/http/goods/goodsList",
					header: {
						token: tokenid
					},
					success(res) {
						console.log(res)
						if (res.data.code == 3) {
							uni.showToast({
								title: res.data.msg,
								success() {
									uni.reLaunch({
										url: "/pages/ajax/ajax"
									})
								}
							})
						} else {
							datalist.value = res.data.data;
						}
					}
				})
			}

			dataload()
			return {
				datalist
			}
		}
	}
</script>

<style scoped>

</style>
